#pragma once


//	enable memory leaks detection (works in debug configuration only)
#ifdef _WINDOWS
#  include "vld.h"
#endif

//	STL defines
#ifdef _DEBUG
#	define _SECURE_SCL 1
#	define _ITERATOR_DEBUG_LEVEL 2	//	enable STL debug iterator
#endif
#define _HAS_STRICT_CONFORMANCE	1	//	enable standard-compilant std::map.erase() method

//	custom assert macro
#include "assert.h"

//	STL headers
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <limits>
#include <algorithm>

//	standart headers
#include <time.h>
#include <math.h>

//	core headers
#include "Types.h"

//	math stuff
#include "MathUtils.h"
#include "Rectangle.h"
#include "Vector.h"
#include "Matrix.h"
#include "Color.h"
#include "KeyValuePair.h"
#include "Smoother.h"

//	platform specific stuff
#include "Platform.h"

//	utils
#include "StringUtils.h"
#include "PathUtils.h"
#include "StlUtils.h"

//	interface headers
#include "ISystem.h"
#include "ITimer.h"
#include "ILog.h"
#include "IConsole.h"
#include "IRenderAPI.h"
#include "IRender.h"
#include "IFont.h"
#include "I2DRender.h"
#include "IInput.h"

//	misc
#include "AppConfig.h"
#include "Errors.h"
#include "ProfilerSection.h"


//	disable some compiler warnings
//#pragma warning(disable: 4244)	//	warning C4244: 'initializing' : conversion from 'uint' to 'float', possible loss of data


//-----------------------------------------------------------------------------
//	Game startup params
//-----------------------------------------------------------------------------
struct SGameStartupParams
{
	XINSTANCE	AppHandle;				//	application handle
	void*			MsgProc;					//	pointer to message processing function

	char*			WindowCaption;
	uint			WindowWidth;
	uint			WindowHeight;
};

//-----------------------------------------------------------------------------
//	Global environment definition
//-----------------------------------------------------------------------------
struct SGlobalEnvironment
{
	ISystem*	pSystem;
	ITimer*		pTimer;
	IConsole*	pConsole;
	IRender*	pRender;
	IInput*		pInput;
};

//-----------------------------------------------------------------------------
//	replace standart NULL pointer define
//-----------------------------------------------------------------------------
#ifdef NULL
	#undef NULL
	//#define NULL nullptr
#endif

//-----------------------------------------------------------------------------
//	some useful defines
//-----------------------------------------------------------------------------
#define SAFE_DELETE(p) { delete p; p = nullptr; }
#define SAFE_RELEASE(p) { if (p) {p->Release(); p = nullptr;} }

//-----------------------------------------------------------------------------
//	profiler macros definitions
//-----------------------------------------------------------------------------
#define PROFILE_FUNCTION() \
	static CProfilerSection _profiler_section(gEnv->pSystem, __FUNCTION__);	\
	CProfilerSectionTrigger _profiler_section_trigger(&_profiler_section);

#define PROFILE_SECTION(name) \
	static CProfilerSection _profiler_section(gEnv->pSystem, name);	\
	CProfilerSectionTrigger _profiler_section_trigger(&_profiler_section);